/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package slisfx.xml;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import slisfx.Globals;
import slisfx.devices.Devicebase;
import slisfx.user.Userbase;

/**
 *
 * @author Rebecca
 */

public class XMLWriter implements Globals{

	public XMLWriter() {
	}
	
	/**
	 * Writes an xml file with to preserve the contents of the database. 
	 *
	 * @throws RushException the rush exception
	 */
	public void writer() {
        try {
            String ENCODING = "UTF-8";
            PrintWriter out;
            out = new PrintWriter(new FileOutputStream("database.xml", false));
            out.println("<?xml version=\"1.0\" encoding = \"" + ENCODING + "\"?>");
            out.println("<DATABASE>");
            out.println(Userbase.getUserbase().toXML());
            out.println(Devicebase.getDevicebase().toXML());
            out.println("</DATABASE>");
            out.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(XMLWriter.class.getName()).log(Level.SEVERE, null, ex);
        }
	}

}